#!/usr/bin/env python3
# -*- coding: utf-8 -*-

with open('/path/to/file', 'r') as f:
    print(f.read())

for line in f.readlines():
    print(line.strip())  # 把末尾的'\n'删掉

with open('/path/to/file', 'w') as f:
    print(f.write('Hello, world!'))
